package two;

import java.util.Scanner;

public class test11087 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = scanner.nextInt();
        }
        int sum = count_inversion(array,0,n-1);
        System.out.println(sum);
    }

    public static int count_inversion(int[] array, int low, int height) {
        int count = 0;
        int middle = 0;
        if (low < height) {
            middle = low + (height-low) / 2;
//            对左段的逆序对进行递归计数
            count = count_inversion(array, low, middle) + count;
//            对右段的逆序对进行递归计数
            count = count_inversion(array, middle + 1, height) + count;
//            加上左半部分元素大于右半部分元素的数量
            count = merge_inversion(array, low, middle, height)+count;
        }
        return count;
    }

    private static int merge_inversion(int[] array, int low, int middle, int height) {
        int count = 0;
        for (int i = low; i <=middle; i++) {
            for (int j = middle+1; j <= height; j++) {
                if(array[i]>array[j]){
                    count++;
                }
            }
        }
        return count;
    }
}
